<?php namespace web\home\controller;
/**
* 接口绑定
*/
class Api
{
	public function __construct()
	{
		Middleware::set('bootstrap');
		Middleware::run();
		Wx::bind();
	}
	public function handler()
	{
		$message=Wx::getMessage();
		$keyword = Db::table( 'keywords' )->where( 'keyword', $message->Content )->first();
		if ($message->MsgType=='text') {
			if ($keyword) {
				$class='module\\'.$keyword['module'].'\Process';
				( new $class() )->handler( $keyword['kid'] );
				exit;
			}else{
				Wx::instance('message')->text(v('config.default_message'));
			}
		}else if ($message->MsgType=='event' && $message->Event=='subscribe') {
			Wx::instance('message')->text(v('welcome.default_message'));
		}

	}




}